import React, { Component } from 'react';
var moment = require('moment');

export default class Timer extends Component{
    constructor() {
        super();
        this.state={
            curtime: ''
        }
    }
    componentDidMount(){
        this.timer = setInterval(() => {
            this.setState({ curtime: moment().format('ll dddd a h:mm:ss') })
        }, 1000)
    }  
    componentWillUnmount() {
        clearInterval(this.timer);
    }
    render(){
        return(
            <span>{this.state.curtime}</span>
        )
    }
}
